<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>员工管理</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/resources/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/resources/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <script src="/resources/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/resources/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/resources/css/amazeui.datatables.min.css"/>
    <link rel="stylesheet" href="/resources/css/app.css">
    <script src="/resources/js/jquery.min.js"></script>

</head>

<body data-type="widgets">

    <script src="/resources/js/theme.js"></script>

    <div class="am-g tpl-g">

        <%--头部开始--%>
        <%@include file="header.jsp" %>
        <%--头部结束--%>

        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">

            <div class="row-content am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <%-- 消息 --%>
                            <div class="container-fluid am-cf">
                                <div class="row">
                                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                                        <div class="page-header-heading"><span class="am-icon-male page-header-heading-icon"></span> ${branch.branName}&nbsp;&nbsp;-&nbsp;&nbsp;员工信息管理
                                            <small>Employee information management</small>
                                        </div>
                                        <p class="page-header-description">对员工信息进行增加、修改、删除、等操作。</p>
                                    </div>
                                    <div class="am-u-lg-3 tpl-index-settings-button">
                                        <%--<button type="button" class="page-header-button"><span class="am-icon-paint-brush"></span> 设置</button>--%>
                                    </div>
                                </div>
                            </div>
                            <%-- 表格 --%>
                            <div class="widget-body  am-fr">
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                                    <div class="am-form-group">
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                               <%-- <button type="button" class="am-btn am-btn-default am-btn-success" onclick="showAndHide();" data-am-modal="{target: '#addEmpModel', width: 900}"><span class="am-icon-plus"></span> 添加员工</button>--%>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- 右上角搜索框 -->
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                                    <div class="am-form-group tpl-table-list-select">
                                       <%-- <select id="searchType" data-am-selected="{btnSize: 'sm'}">
                                            <option value="emNo">工号</option>
                                            <option value="emName">姓名</option>
                                            <option value="emTel">联系电话</option>
                                            <option value="loginName">登录名</option>
                                        </select>--%>
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                      <%--  <input type="text" class="am-form-field" id="searchContent">--%>
                                        <span class="am-input-group-btn">
                                        <%--    <button class="am-btn am-btn-default am-btn-success tpl-table-list-field am-icon-search" id="searchBtn" type="button"></button>--%>
                                        </span>
                                    </div>
                                </div>
                                <!-- 员工表开始 -->
                                <div class="am-u-sm-12 tableDiv">
                                    <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black">
                                        <thead>
                                            <tr>
                                                <th class="am-text-center">工号</th>
                                                <th class="am-text-center">头像</th>
                                                <th class="am-text-center">姓名</th>
                                                <th class="am-text-center">性别</th>
                                                <th class="am-text-center">年龄</th>
                                                <th class="am-text-center">电话号码</th>
                                                <th class="am-text-center">岗位</th>
                                                <th class="am-text-center">工资</th>
                                                <th class="am-text-center">入职日期</th>
                                                <th class="am-text-center">员工状态</th>
                                                <th class="am-text-center">操作</th>
                                            </tr>
                                        </thead>
                                        <tbody class="am-text-center">
                                            <c:forEach items="${pageInfo.list }" var="e">
                                                <tr>
                                                    <td>${e.employee.emNo }</td>
                                                    <td>
                                                        <a href="#" onclick="showPhotoFun('${e.employee.emId}');" data-am-modal="{target: '#showPictureModel', closeViaDimmer: 0, width: '400px', height: '520px'}">头像</a>
                                                    </td>
                                                    <td>${e.employee.emName}</td>
                                                    <td>
                                                        <c:choose>
                                                            <c:when test="${e.employee.emsex == 1}">男</c:when>
                                                            <c:when test="${e.employee.emsex == 0}">女</c:when>
                                                        </c:choose>
                                                    </td>
                                                    <td>${e.employee.emage }岁</td>
                                                    <td>${e.employee.emTel }</td>
                                                    <td>${e.employeeType.typeInstruct}</td>
                                                    <td>￥${e.employee.emWage }</td>
                                                    <td>${fn:substring(e.employee.entryDate, 0, 10)}</td>
                                                    <td>
                                                        <c:choose>
                                                            <c:when test="${e.employee.emState == 1}">在职</c:when>
                                                            <c:when test="${e.employee.emState == 0}">离职</c:when>
                                                        </c:choose>
                                                    </td>
                                                    <td>
                                                        <button type="button" class="am-btn am-btn-xs am-btn-secondary" onclick="editEmpFun('${e.employee.emId}')" data-am-modal="{target: '#addEmpModel', width: 900}">
                                                            <span class="am-icon-eye"></span> 查看
                                                        </button>
                                                        <button type="button" class="am-btn am-btn-xs am-btn-danger" onclick="delEmpFun('${e.employee.emId}')"<%--data-am-modal="{target: '#delEmpConfirm'}"--%>>
                                                            <span class="am-icon-trash-o"></span> 删除
                                                        </button>
                                                    </td>
                                                </tr>
                                            </c:forEach>
                                        <!-- more data -->
                                        </tbody>
                                    </table>
                                </div>
                                <!-- 员工表结束 -->

                                <!-- 分页开始 -->
                                <div class="am-u-lg-12 am-cf paging">

                                    <!-- 分页文字信息，其中分页信息都封装在pageInfo中 -->
                                    <div class="col-md-6">
                                        当前第：${pageInfo.pageNum }页，总共：${pageInfo.pages }页，总共：${pageInfo.total }条记录
                                    </div>
                                    <div class="am-fr">
                                        <ul class="am-pagination tpl-pagination">
                                            <!-- 首页 -->
                                            <li><a href="/employeeController/findbrEmployee?branch=${branch.branId}&pn=1">首页</a></li>
                                            <!-- 上一页 -->
                                            <c:if test="${pageInfo.hasPreviousPage }">
                                                <li>
                                                    <a href="/employeeController/findbrEmployee?branch=${branch.branId}&pn=${pageInfo.pageNum-1 }" aria-label="Previous">
                                                        <span aria-hidden="true">&laquo;</span>
                                                    </a>
                                                </li>
                                            </c:if>
                                            <!-- 循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接 -->
                                            <c:forEach items="${pageInfo.navigatepageNums }" var="page_Num">
                                                <c:if test="${page_Num == pageInfo.pageNum }">
                                                    <li class="am-active"><a href="/employeeController/findbrEmployee?branch=${branch.branId}&pn=${page_Num }">${page_Num }</a></li>
                                                </c:if>
                                                <c:if test="${page_Num != pageInfo.pageNum }">
                                                    <li><a href="/employeeController/findbrEmployee?branch=${branch.branId}&pn=${page_Num }">${page_Num }</a></li>
                                                </c:if>
                                            </c:forEach>
                                            <!-- 下一页 -->
                                            <c:if test="${pageInfo.hasNextPage }">
                                                <li>
                                                    <a href="/employeeController/findbrEmployee?branch=${branch.branId}&pn=${pageInfo.pageNum+1 }" aria-label="Next">
                                                        <span aria-hidden="true">&raquo;</span>
                                                    </a>
                                                </li>
                                            </c:if>
                                            <!-- 末页 -->
                                            <li><a href="/employeeController/findbrEmployee?branch=${branch.branId}&pn=${pageInfo.pages }">末页</a></li>
                                        </ul>
                                    </div>
                                </div>
                                <!-- 分页结束 -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 添加员工模态框开始 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="addEmpModel">
        <div class="am-modal-dialog">
            <div class="am-modal-bd" style="padding: 1px;">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf" style="margin: 0;">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl"><h2>员工表单</h2></div>
                                <div class="widget-function am-fr">
                                    <a href="javascript: void(0)" class="am-close am-close-spin clearForm">&times;</a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form class="am-form tpl-form-border-form tpl-form-border-br" id="addEmpForm">

                                    <!-- 数据库主键(隐藏) -->
                                    <div class="am-form-group am-hide">
                                        <label class="am-u-sm-3 am-form-label">emId</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="emId" class="am-form-field tpl-form-no-bg emId">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small></small>
                                        </div>
                                    </div>

                                    <!-- 头像 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">头像</label>
                                        <div class="am-u-sm-6">
                                            <div class="tpl-form-file-img">
                                                <img class="imagePhoto" style="width: 160px; height: 210px;">
                                            </div>
                                            <br>
                                            <div class="am-form-group am-form-file">
                                                <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                                    <i class="am-icon-cloud-upload"></i> 上传头像
                                                </button>
                                                <input type="file" class="addEmPhoto">
                                                <input type="text" name="emPhoto" class="am-hide strPhoto">
                                            </div>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipemPhoto">请上传头像！</small>
                                        </div>
                                    </div>

                                    <!-- 工号 -->
                                    <div class="am-form-group showAndHide">
                                        <label class="am-u-sm-3 am-form-label">工号</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="emNo" class="am-form-field tpl-form-no-bg emNo" disabled>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipemNo" style="color: green">√</small>
                                        </div>
                                    </div>

                                    <!-- 姓名 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">姓名</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="emName" class="tpl-form-input emName" placeholder="请输入真实姓名">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipemName">此项为必填项！</small>
                                        </div>
                                    </div>

                                    <!-- 性别 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">性别</label>
                                        <div class="am-u-sm-6">
                                            <div class="am-form-group">
                                                <label class="am-radio-inline">
                                                    <input type="radio" name="emsex" class="emsex" value="1" checked> 男
                                                </label>
                                                <label class="am-radio-inline">
                                                    <input type="radio" name="emsex" class="emsex" value="0"> 女
                                                </label>
                                            </div>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small></small>
                                        </div>
                                    </div>

                                    <!-- 员工类型 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">员工类型</label>
                                        <div class="am-u-sm-6">
                                            <select name="emTypeId" class="emTypeId" data-am-selected>
                                                <%-- ------------------------- --%>
                                            </select>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipemTypeId"></small>
                                        </div>
                                    </div>

                                    <!-- 所属分店 -->
                                    <div class="am-form-group showAndHide">
                                        <label class="am-u-sm-3 am-form-label">分店</label>
                                        <div class="am-u-sm-6">
                                            <select name="branchesId" class="branchesId" data-am-selected>
                                                <%-- ------------------------- --%>
                                            </select>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipbranchesId"></small>
                                        </div>
                                    </div>

                                    <!-- 在职否 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">在职否</label>
                                        <div class="am-u-sm-6">
                                            <div class="am-form-group">
                                                <label class="am-radio-inline">
                                                    <input type="radio" name="emState" value="1" class="emState" checked> 在职
                                                </label>
                                                <label class="am-radio-inline">
                                                    <input type="radio" name="emState" value="0" class="emState"> 离职
                                                </label>
                                            </div>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipstate"></small>
                                        </div>
                                    </div>

                                    <!-- 出生日期 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">出生日期</label>
                                        <div class="am-u-sm-6">
                                            <div class="am-input-group am-datepicker-date" data-am-datepicker="{format: 'yyyy-mm-dd', viewMode: 'years'}">
                                                <input type="text" class="am-form-field embirthday" name="embirthday" onchange="countEmage();" placeholder="请选择出生日期" readonly>
                                                <span class="am-input-group-btn am-datepicker-add-on">
                                                    <button class="am-btn am-btn-default" type="button">
                                                        <span class="am-icon-calendar"></span>
                                                    </button>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipembirthday">此项为必填项！</small>
                                        </div>
                                    </div>

                                    <!-- 年龄 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">年龄</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="emage" class="tpl-form-input emage" placeholder="年龄由出生日期计算而来" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipemage">此项为必填项！</small>
                                        </div>
                                    </div>

                                    <!-- 入职日期 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">入职日期</label>
                                        <div class="am-u-sm-6">
                                            <div class="am-input-group am-datepicker-date" data-am-datepicker="{format: 'yyyy-mm-dd', viewMode: 'years'}">
                                                <input type="text" class="am-form-field entryDate" name="entryDate" placeholder="请选择入职日期" readonly>
                                                <span class="am-input-group-btn am-datepicker-add-on">
                                                        <button class="am-btn am-btn-default" type="button"><span class="am-icon-calendar"></span> </button>
                                                    </span>
                                            </div>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipentryDate">此项为必填项！</small>
                                        </div>
                                    </div>

                                    <!-- 离职时间 -->
                                    <div class="am-form-group showAndHide">
                                        <label class="am-u-sm-3 am-form-label">离职时间</label>
                                        <div class="am-u-sm-6">
                                            <div class="am-input-group am-datepicker-date" data-am-datepicker="{format: 'yyyy-mm-dd', viewMode: 'years'}">
                                                <input type="text" class="am-form-field departureDate" name="departureDate" placeholder="请选择离职时间" readonly>
                                                <span class="am-input-group-btn am-datepicker-add-on">
                                                        <button class="am-btn am-btn-default" type="button"><span class="am-icon-calendar"></span> </button>
                                                    </span>
                                            </div>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipdepartureDate"></small>
                                        </div>
                                    </div>

                                    <!-- 电话号码 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">联系电话</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="emTel" class="am-form-field tpl-form-no-bg emTel" placeholder="请输入电话">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipemTel">此项为必填项！</small>
                                        </div>
                                    </div>

                                    <!-- 密码 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">密码</label>
                                        <div class="am-u-sm-6">
                                            <input type="password" name="password" value="123456" class="am-form-field tpl-form-no-bg password" placeholder="密码为6-16位！">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tippassword">此项为必填项！</small>
                                        </div>
                                    </div>

                                    <!-- 确认密码 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">确认密码</label>
                                        <div class="am-u-sm-6">
                                            <input type="password" name="password1" class="am-form-field tpl-form-no-bg password1" placeholder="默认密码为：123456">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tippassword1">此项为必选项！</small>
                                        </div>
                                    </div>

                                    <!-- 工资 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">工资</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="emWage" class="am-form-field tpl-form-no-bg emWage" placeholder="员工工资格式：5000.00">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipemWage">此项为必填项！</small>
                                        </div>
                                    </div>

                                    <!-- 登录名 默认电话号码 -->
                                    <div class="am-form-group showAndHide">
                                        <label class="am-u-sm-3 am-form-label">登录名</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="loginName" class="am-form-field tpl-form-no-bg loginName" placeholder="格式：英文+数字（默认联系电话）">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tiploginName"></small>
                                        </div>
                                    </div>

                                    <!-- 证件类型 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">证件类型</label>
                                        <div class="am-u-sm-6">
                                            <select name="documentType" class="documentType" data-am-selected>
                                                <option value="身份证">身份证</option>
                                                <option value="户口本">护照</option>
                                                <option value="其他">其他</option>
                                            </select>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipdocumentType"></small>
                                        </div>
                                    </div>

                                    <!-- 证件编号 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">证件编号</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="documentNo" class="am-form-field tpl-form-no-bg documentNo" placeholder="请输入证件编号">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipdocumentNo"></small>
                                        </div>
                                    </div>

                                    <!-- 地址 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">联系地址</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="emAddress" class="am-form-field tpl-form-no-bg emAddress" placeholder="请输入员工住址">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipemAddress"></small>
                                        </div>
                                    </div>

                                    <!-- 备注 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">备注</label>
                                        <div class="am-u-sm-6">
                                            <textarea rows="6" name="emNote" class="emNote" placeholder="请输入员工备注，最多不超过200字" maxlength="200"></textarea>
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small class="tipemNote"></small>
                                        </div>
                                    </div>

                                    <!-- 按钮 -->
                                    <div class="am-form-group">
                                        <div class="am-u-sm-12">
                                            <button type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success clearForm"><i class="am-icon-close"></i> 关闭</button>
                                            <button type="button" class="am-btn am-btn-success tpl-btn-bg-color-success" id="addSubmitBtn"><i class="am-icon-floppy-o"></i> 提交</button>
                                            <button type="button" class="am-btn am-btn-success tpl-btn-bg-color-success" id="updateSubmitBtn" onclick="updateEmpFun();"><i class="am-icon-floppy-o"></i> 更新</button>
                                        </div>
                                    </div>

                                </form>

                            </div>
                        </div>
                    </div>
                </div>
                <!-- 整个表单结束 -->
            </div>
        </div>
    </div>
    <!-- 添加员工模态框结束 -->

    <!-- 查看头像模态框开始 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="showPictureModel">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">
                员工头像
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <div class="am-modal-bd">
                <div class="tpl-form-file-img">
                    <img alt="未上传头像" class="imagePhoto" width="380px" height="460px">
                </div>
            </div>
        </div>
    </div>
    <!-- 查看头像模态框结束 -->

    <!-- 删除员工提示警告框开始 -->
    <div class="am-modal am-modal-confirm" tabindex="-1" id="delEmpConfirm">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">删除警告</div>
            <div class="am-modal-bd">
                您，确定要删除这条记录吗？
            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn" data-am-modal-cancel>取消</span>
                <span class="am-modal-btn" data-am-modal-confirm>确定</span>
            </div>
        </div>
    </div>
    <!-- 删除员工提示警告框结束 -->

    <script src="/resources/js/amazeui.min.js"></script>
    <script src="/resources/js/amazeui.datatables.min.js"></script>
    <script src="/resources/js/dataTables.responsive.min.js"></script>
    <script src="/resources/js/app.js"></script>
    <script src="/resources/jsutlis/fileutli.js"></script>
    <script src="/resources/js/employee.form.validation.js"></script>
</body>

</html>